package main

type ListNode struct {
	Val  int
	Next *ListNode
}

func getDecimalValue(head *ListNode) int {
	cache := make([]int, 30)
	var result int
	var j uint
	result = 0
	node := head
	for node != nil {
		cache = append(cache, int(node.Val))
		node = node.Next
	}
	j = 0
	for i := len(cache) - 1; i >= 0; i-- {
		result += int((1 << j) * cache[i])
		j += 1
	}
	return result
}
